import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { OperationLog } from './entities/operation-log.entity';

@Injectable()
export class LogsService {
  constructor(
    @InjectRepository(OperationLog)
    private logsRepository: Repository<OperationLog>,
  ) {}

  async createLog(logData: Partial<OperationLog>) {
    const log = this.logsRepository.create(logData);
    return this.logsRepository.save(log);
  }

  async findAll() {
    return this.logsRepository.find({
      order: { createTime: 'DESC' },
    });
  }
} 